//
//  BCSinceUptime.h
//  BCFoundation
//
//  Created by chasel. c on 2022/11/1.
//  记录 进入后台-再次进入前台的时间

#import <Foundation/Foundation.h>
@class BCSinceUptime;

NS_ASSUME_NONNULL_BEGIN

@protocol BCSinceUptimeDelegate <NSObject>

@optional

/// 即将退出后台
/// @param uptime uptime description
/// @param notification notification description
- (void)uptimeWillResignActive:(BCSinceUptime *)uptime notification:(NSNotification * )notification;


/// 进入前台
/// @param uptime uptime description
/// @param notification notification description
- (void)uptimeDidBecomeActive:(BCSinceUptime *)uptime notification:(NSNotification * )notification;


@end

@interface BCSinceUptime : NSObject

/// 上次离开的时间
@property (nonatomic) NSTimeInterval time;

/// 单例
+ (instancetype)shared;

/// 开始监测
- (void)start;

/// 结束
- (void)end;


/// 绑定监听
/// @param delegate delegate description
- (void)bind:(id<BCSinceUptimeDelegate>)delegate;
/// 解绑监听
/// @param delegate delegate description
- (void)unbind:(id<BCSinceUptimeDelegate>)delegate;


/// 系统当前运行了多长时间
+ (NSTimeInterval)uptimeSinceLastBoot;

@end

NS_ASSUME_NONNULL_END
